<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>07_自定义js对象</title>
</head>
<body>

<table border="1px" id="goodsT">
    <caption>商品表</caption>
    <tr>
        <th>名称</th>
        <th>价格</th>
        <th>数量</th>
    </tr>
</table>
</body>
<script>
    let productArr = [
        {title: '苹果', price: '80', num: '2500'},
        {title: '梨子', price: '70', num: '2000'},
        {title: '苹果', price: '80', num: '2500'}
    ];
    for (i of productArr) {
        let tr = document.createElement("tr");
        let tdTit = document.createElement("td");
        let tdPri = document.createElement("td");
        let tdNum = document.createElement("td");
        tdTit.innerHTML = productArr[0].title;
        tdPri.innerHTML = productArr[0].price;
        tdNum.innerHTML = productArr[0].num;
        tr.append(tdTit, tdPri, tdNum);
        console.log(tr);
        let tit =document.getElementById('goodsT');
        tit.append(tr);

    }


</script>
</html>